home *** CD-ROM | disk | FTP | other *** search
- ===========================================================================
- BBS: The Abacus * HST/DS * Potterville MI
- Date: 05-23-93 (13:10) Number: 8
- From: MATT GRASSE Refer#: NONE
- To: JIM BURNS Recvd: NO
- Subj: Ascii Boxes Conf: (36) C Language
- ---------------------------------------------------------------------------
- JB>little idea to write directly to the video board, but I'm
- JB>not sure it really works and then what about portability is
- JB>the color video address always xB8000 ?
-
- Jim -
- The video address will always be 0xB8000 unless you're using a
- monochrome display and then it would begin at 0xB0000. Otherwise
- 0xB8000 will always point to the begining of the video memory on PCs
- Here's a simple function that should fill the screen with a character,
- wait for a keypress and then exit.
-
- /********
- * This program is released to public domain and al that other good
- * stuff...
- * This is untested but it should work.
- ********/
-
- #define VID_ADDR 0xB8000000 /* value for far pointer to video mem */
- #define NORMAL 0x87 /* attribute value for normal text */
- #define ROWS 25
- #define COLS 80
-
- void showch(unsigned char, unsigned char);
- main()
- ä
- unsigned char ch, attirb; /* the character and its attribute */
- /* keep theses unsigned or things */
- /* may not look right */
- printf("Enter a char");
- ch = getch();
- attrib = NORMAL;
- showch(ch, attrib);
- getch();
- å
-
- /********
- * showch() - this function fills the screen with the specified
- * character
- **************/
- void showch(unsigned char ch, unsigned char attrib)
- ä
- int far *farptr = (int far *)VID_ADDR; /* to point to video memory */
- int col, row;
-
- for(row = 0; row < ROWS; row++)
- for(col=0; col < COLS; col++)
- *(farptr + row*COLS + col) = ch ö attrib<<8;
- å
-
- the final line calculates the memory address for a given row and column
- on the text screen. Each char on the screen is represented by two bytes
- the attribute and then the char. So attrib is shifted over 8 bits to
- put it at the begining of those two bytes and then ORed to the char.
- This should always work, it win't scroll the screen and it's fast. If
- you're writing you're program with quickC (and probably some other
- compilers that allow you to run the program for the editor and then
- capture the output) you may have to run it rom the prompt to get it to
- run properly. The only drawback to this method is I don't thibnk you can
- the output of this program if you run it from another. If you need any more
- info drop me a line.
-
- --- PTQWK 1.00 Beta-2 (Eval.)
- * Origin: The Biggest Little BBS In Enon, Ohio! (1:110/270)
- SEEN-BY: 1/211 11/2 4 108/89 110/10 15 35 69 150 210 255 270 290 310 375
- SEEN-BY: 110/515 540 154/40 77 157/2 159/100 125 575 950 396/1 2270/1
- SEEN-BY: 2440/5
-